import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:gourmet/color/hex.dart';
import 'package:gourmet/ui/coupon_shape_border.dart';
import 'package:gourmet/utils/colors.dart';
import 'package:gourmet/utils/radian.dart';
import 'package:gourmet/utils/styles.dart';

class MineRedEnvelopeController extends GetxController {}

class MineRedEnvelopePage extends GetView<MineRedEnvelopeController> {
  const MineRedEnvelopePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: HexColor(ColorsUtils.colorF7f7),
      appBar: AppBar(
        systemOverlayStyle: SystemUiOverlayStyle.dark,
        backgroundColor: HexColor(ColorsUtils.colorF7f7),
        leading: GestureDetector(
          onTap: Get.back,
          child: Icon(
            CupertinoIcons.chevron_back,
            size: 20,
            color: HexColor(ColorsUtils.color0000),
          ),
        ),
        centerTitle: true,
        title: Text(
          '我的红包',
          style: StylesUtils.customTextStyle(
            fontSize: StylesUtils.fontSize18,
            color: ColorsUtils.color0000,
            fontWeight: FontWeight.w700,
          ),
        ),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.only(top: 10),
              child: Material(
                color: Colors.white,
                shape: const CouponShapeBorder(lineRate: 0.3),
                child: Container(
                  constraints:
                      const BoxConstraints.expand(width: 345, height: 120),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SizedBox(
                        height: 120,
                        width: 345 * 0.3,
                        child: Stack(
                          children: [
                            Column(
                              children: [
                                Container(
                                  margin: const EdgeInsets.only(top: 35),
                                  alignment: Alignment.center,
                                  child: Text.rich(
                                    TextSpan(
                                      children: [
                                        TextSpan(
                                          text: '10',
                                          style: StylesUtils.customTextStyle(
                                              color: ColorsUtils.colorFf64,
                                              fontWeight: FontWeight.w700,
                                              fontSize: StylesUtils.fontSize30),
                                        ),
                                        TextSpan(
                                          text: '元',
                                          style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorFf64,
                                            fontSize: StylesUtils.fontSize12,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 5),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '无限制',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.color7979,
                                        fontSize: StylesUtils.fontSize12),
                                  ),
                                ),
                              ],
                            ),
                            Positioned(
                              top: 0,
                              left: 0,
                              height: 20,
                              width: 50,
                              child: Container(
                                decoration: BoxDecoration(
                                    borderRadius: const BorderRadius.only(
                                        topLeft: Radius.circular(10),
                                        bottomRight: Radius.circular(10)),
                                    color: HexColor(ColorsUtils.colorFf99)),
                                alignment: Alignment.center,
                                child: Text(
                                  '仅剩7天',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize12),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 10, top: 20, right: 15),
                          child: Column(
                            children: [
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    '通用红包',
                                    style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color0000,
                                      fontSize: StylesUtils.fontSize16,
                                      fontWeight: FontWeight.w700,
                                    ),
                                  ),
                                  Container(
                                    //linear-gradient(90deg, rgba(255, 153, 0, 1) 0%, rgba(255, 153, 0, 1) 0%, rgba(254, 70, 1, 1) 100%, rgba(254, 70, 1, 1) 100%)
                                    constraints: const BoxConstraints.expand(
                                        width: 60, height: 25),
                                    alignment: Alignment.center,
                                    decoration: BoxDecoration(
                                      gradient: LinearGradient(
                                        colors: [
                                          ColorsUtils.rgba(255, 153, 0, 1),
                                          ColorsUtils.rgba(255, 153, 0, 1),
                                          ColorsUtils.rgba(254, 70, 1, 1),
                                          ColorsUtils.rgba(254, 70, 1, 1)
                                        ],
                                        stops: const [0, 0, 1, 1],
                                        begin: Alignment.centerLeft,
                                        end: Alignment.centerRight,
                                        transform: GradientRotation(
                                          RadianUtils.angleToRadian(90),
                                        ),
                                      ),
                                      borderRadius: BorderRadius.circular(13),
                                    ),
                                    child: Text(
                                      '去使用',
                                      style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize12,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              Container(
                                margin:
                                    const EdgeInsets.symmetric(vertical: 15),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '平台通用',
                                  style: StylesUtils.customTextStyle(
                                    color: ColorsUtils.color7979,
                                    fontSize: StylesUtils.fontSize13,
                                  ),
                                ),
                              ),
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    '有效期至2025.01.10',
                                    style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize12,
                                        color: ColorsUtils.color7979),
                                  ),
                                  Text.rich(
                                    TextSpan(
                                      children: [
                                        TextSpan(
                                          text: '使用规则',
                                          style: StylesUtils.customTextStyle(
                                              fontSize: StylesUtils.fontSize12,
                                              color: ColorsUtils.color9999),
                                        ),
                                        WidgetSpan(
                                            child: Icon(
                                              CupertinoIcons.chevron_down,
                                              size: 10,
                                              color: HexColor(
                                                  ColorsUtils.color9999),
                                            ),
                                            alignment:
                                                PlaceholderAlignment.middle),
                                      ],
                                    ),
                                  ),
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.only(top: 10),
              child: Material(
                color: Colors.white,
                shape: const CouponShapeBorder(lineRate: 0.3),
                child: Container(
                  constraints:
                      const BoxConstraints.expand(width: 345, height: 120),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SizedBox(
                        height: 120,
                        width: 345 * 0.3,
                        child: Stack(
                          children: [
                            Column(
                              children: [
                                Container(
                                  margin: const EdgeInsets.only(top: 35),
                                  alignment: Alignment.center,
                                  child: Text.rich(
                                    TextSpan(
                                      children: [
                                        TextSpan(
                                          text: '4',
                                          style: StylesUtils.customTextStyle(
                                              color: ColorsUtils.colorFf64,
                                              fontWeight: FontWeight.w700,
                                              fontSize: StylesUtils.fontSize30),
                                        ),
                                        TextSpan(
                                          text: '元',
                                          style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorFf64,
                                            fontSize: StylesUtils.fontSize12,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 5),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '满100可用',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.color7979,
                                        fontSize: StylesUtils.fontSize12),
                                  ),
                                ),
                              ],
                            ),
                            Positioned(
                              top: 0,
                              left: 0,
                              height: 20,
                              width: 50,
                              child: Container(
                                decoration: BoxDecoration(
                                    borderRadius: const BorderRadius.only(
                                        topLeft: Radius.circular(10),
                                        bottomRight: Radius.circular(10)),
                                    color: HexColor(ColorsUtils.colorFf99)),
                                alignment: Alignment.center,
                                child: Text(
                                  '仅剩3天',
                                  style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize12),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 10, top: 20, right: 15),
                          child: Column(
                            children: [
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    '配送费抵扣红包',
                                    style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color0000,
                                      fontSize: StylesUtils.fontSize16,
                                      fontWeight: FontWeight.w700,
                                    ),
                                  ),
                                  Container(
                                    //linear-gradient(90deg, rgba(255, 153, 0, 1) 0%, rgba(255, 153, 0, 1) 0%, rgba(254, 70, 1, 1) 100%, rgba(254, 70, 1, 1) 100%)
                                    constraints: const BoxConstraints.expand(
                                        width: 60, height: 25),
                                    alignment: Alignment.center,
                                    decoration: BoxDecoration(
                                      gradient: LinearGradient(
                                        colors: [
                                          ColorsUtils.rgba(255, 153, 0, 1),
                                          ColorsUtils.rgba(255, 153, 0, 1),
                                          ColorsUtils.rgba(254, 70, 1, 1),
                                          ColorsUtils.rgba(254, 70, 1, 1)
                                        ],
                                        stops: const [0, 0, 1, 1],
                                        begin: Alignment.centerLeft,
                                        end: Alignment.centerRight,
                                        transform: GradientRotation(
                                          RadianUtils.angleToRadian(90),
                                        ),
                                      ),
                                      borderRadius: BorderRadius.circular(13),
                                    ),
                                    child: Text(
                                      '去使用',
                                      style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize12,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              Container(
                                margin:
                                    const EdgeInsets.symmetric(vertical: 15),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '平台通用',
                                  style: StylesUtils.customTextStyle(
                                    color: ColorsUtils.color7979,
                                    fontSize: StylesUtils.fontSize13,
                                  ),
                                ),
                              ),
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    '有效期至2025.01.10',
                                    style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize12,
                                        color: ColorsUtils.color7979),
                                  ),
                                  Text.rich(
                                    TextSpan(
                                      children: [
                                        TextSpan(
                                          text: '使用规则',
                                          style: StylesUtils.customTextStyle(
                                              fontSize: StylesUtils.fontSize12,
                                              color: ColorsUtils.color9999),
                                        ),
                                        WidgetSpan(
                                            child: Icon(
                                              CupertinoIcons.chevron_down,
                                              size: 10,
                                              color: HexColor(
                                                  ColorsUtils.color9999),
                                            ),
                                            alignment:
                                                PlaceholderAlignment.middle),
                                      ],
                                    ),
                                  ),
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.only(top: 10),
              child: Material(
                color: Colors.white,
                shape: const CouponShapeBorder(lineRate: 0.3),
                child: Container(
                  constraints:
                      const BoxConstraints.expand(width: 345, height: 120),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SizedBox(
                        height: 120,
                        width: 345 * 0.3,
                        child: Stack(
                          children: [
                            Column(
                              children: [
                                Container(
                                  margin: const EdgeInsets.only(top: 35),
                                  alignment: Alignment.center,
                                  child: Text.rich(
                                    TextSpan(
                                      children: [
                                        TextSpan(
                                          text: '10',
                                          style: StylesUtils.customTextStyle(
                                              color: ColorsUtils.colorFf64,
                                              fontWeight: FontWeight.w700,
                                              fontSize: StylesUtils.fontSize30),
                                        ),
                                        TextSpan(
                                          text: '个',
                                          style: StylesUtils.customTextStyle(
                                            color: ColorsUtils.colorFf64,
                                            fontSize: StylesUtils.fontSize12,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 5),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '无限制',
                                    style: StylesUtils.customTextStyle(
                                        color: ColorsUtils.color7979,
                                        fontSize: StylesUtils.fontSize12),
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 10, top: 20, right: 15),
                          child: Column(
                            children: [
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    '邀请有奖红包0.5元',
                                    style: StylesUtils.customTextStyle(
                                      color: ColorsUtils.color0000,
                                      fontSize: StylesUtils.fontSize16,
                                      fontWeight: FontWeight.w700,
                                    ),
                                  ),
                                  Container(
                                    //linear-gradient(90deg, rgba(255, 153, 0, 1) 0%, rgba(255, 153, 0, 1) 0%, rgba(254, 70, 1, 1) 100%, rgba(254, 70, 1, 1) 100%)
                                    constraints: const BoxConstraints.expand(
                                        width: 60, height: 25),
                                    alignment: Alignment.center,
                                    decoration: BoxDecoration(
                                      gradient: LinearGradient(
                                        colors: [
                                          ColorsUtils.rgba(255, 153, 0, 1),
                                          ColorsUtils.rgba(255, 153, 0, 1),
                                          ColorsUtils.rgba(254, 70, 1, 1),
                                          ColorsUtils.rgba(254, 70, 1, 1)
                                        ],
                                        stops: const [0, 0, 1, 1],
                                        begin: Alignment.centerLeft,
                                        end: Alignment.centerRight,
                                        transform: GradientRotation(
                                          RadianUtils.angleToRadian(90),
                                        ),
                                      ),
                                      borderRadius: BorderRadius.circular(13),
                                    ),
                                    child: Text(
                                      '去使用',
                                      style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize12,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                              Container(
                                margin:
                                    const EdgeInsets.symmetric(vertical: 15),
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  '平台通用',
                                  style: StylesUtils.customTextStyle(
                                    color: ColorsUtils.color7979,
                                    fontSize: StylesUtils.fontSize13,
                                  ),
                                ),
                              ),
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Text(
                                    '有效期至2025.01.10',
                                    style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize12,
                                        color: ColorsUtils.color7979),
                                  ),
                                  Text.rich(
                                    TextSpan(
                                      children: [
                                        TextSpan(
                                          text: '使用规则',
                                          style: StylesUtils.customTextStyle(
                                              fontSize: StylesUtils.fontSize12,
                                              color: ColorsUtils.color9999),
                                        ),
                                        WidgetSpan(
                                            child: Icon(
                                              CupertinoIcons.chevron_down,
                                              size: 10,
                                              color: HexColor(
                                                  ColorsUtils.color9999),
                                            ),
                                            alignment:
                                                PlaceholderAlignment.middle),
                                      ],
                                    ),
                                  ),
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: 30),
              alignment: Alignment.center,
              child: Wrap(
                spacing: 10,
                alignment: WrapAlignment.center,
                crossAxisAlignment: WrapCrossAlignment.center,
                children: [
                  GestureDetector(
                    onTap: () {},
                    child: Text(
                      '查看失效红包',
                      style: StylesUtils.customTextStyle(
                        color: ColorsUtils.color7979,
                      ),
                    ),
                  ),
                  Container(
                    constraints:
                        const BoxConstraints.expand(width: 2, height: 15),
                    color: HexColor(ColorsUtils.colorCccc),
                  ),
                  GestureDetector(
                    onTap: () {},
                    child: Text(
                      '平台红包说明',
                      style: StylesUtils.customTextStyle(
                        color: ColorsUtils.color7979,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
